package com.wmapp.domain;

import com.wmapp.utils.Pserver;
import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONArray;

import com.wmapp.utils.SimpleStringUtils;


/**
 * conference domain
 * @author dengl
 *
 */
public class Conference {
	private String number;
	private String name;
	private String topic;//description
	private String password;
	private String chairpassword;
	private String beginLimit;
	private String beginTime; 
	private String endLimit;
	private String endTime;
	private String bandwidth;
	private String maxAudioPorts;
	private String maxVideoPorts;
	private String reservedAudioPorts;//boolean
	private String reservedVideoPorts;//boolean
	private String encryptEnabled;//boolean
	private String encryptForced;//boolean
	private String callInType;//
	private String users;//conference participant count
	private String muteOnJoin;
	private String audioFormats;
	private String h263cif4Enabled;//boolean
	private String h263_1998Enabled;//boolean
	private String h264Enabled;//boolean
	private String h264Definition;
	private String h239Bandwidth;
	private String h239Enabled;//boolean
	private String h239Codec;
	private String textPosition;
	private String textFont;
	private String textColor;
	private String textBgEnabled;
	private String textBgColor;
	private String textBgTransparency;
    private String textDisplayTime;
	private String broadcastEnabled;
	private String broadcastBandwidth;
	private String broadcastPassword;
	private String broadcastNumLimit;
	private String group;//contains this conference group,if empty,every user can see this conference
    private String paused;
	
	//actually participants
	private List<ConfParticipant> participants=new ArrayList<ConfParticipant>();
	private String participantsJSON;
	
	private String encrypt;
	private String[] audioFormatsArray;
	
	public static final String[] ADD_PARAM_FIELDS = { "number", "name",
			"topic", "password", "chairpassword", "endLimit", "endTime",
			"bandwidth", "maxAudioPorts", "maxVideoPorts",
			"reservedAudioPorts", "reservedVideoPorts", "encryptEnabled",
			"encryptForced", "callInType", "muteOnJoin", "audioFormats",
			"h263cif4Enabled", "h264Enabled", "h264Definition",
			"h239Bandwidth", "h239Enabled", "h239Codec", "textPosition",
			"textFont", "textColor", "textBgEnabled", "textBgColor", "textDisplayTime",
			"broadcastEnabled", "broadcastBandwidth", "broadcastNumLimit",
			"broadcastPassword","group" };
	public static final String[] MODIFY_PARAM_FIELDS = { "number", "name",
		"topic", "password", "chairpassword", "endLimit", "endTime",
		"bandwidth", "maxAudioPorts", "maxVideoPorts",
		"reservedAudioPorts", "reservedVideoPorts", "encryptEnabled",
		"encryptForced", "callInType", "muteOnJoin", "audioFormats",
		"h263cif4Enabled", "h264Enabled", "h264Definition",
		"h239Bandwidth", "h239Enabled", "h239Codec", "textPosition",
		"textFont", "textColor", "textBgEnabled", "textBgColor","textDisplayTime",
		"broadcastEnabled", "broadcastBandwidth", "broadcastNumLimit",
		"broadcastPassword","group" };
	
	public final static String[] ONLINE_GRID_COLS={"pause","number","name","users","group","endTime"};
	
	public String getEncrypt() {
		return encrypt;
	}

    public String getPause() {
            StringBuffer ret = new StringBuffer();
            ret.append("<div>");
            if (this.paused != null && this.paused.equals("true")) {
                ret.append(SimpleStringUtils.join("<span><img src=", Pserver.getInstance().getContextPath(), "/styles/default/images/pause_blue.png></span>"));
            } else {
                ret.append(SimpleStringUtils.join("<span><img src=", Pserver.getInstance().getContextPath(), "/styles/default/images/restart.png></span>"));
            }
            ret.append("</div>");
            return ret.toString();
	}

        public String getPaused() {
		return paused;
	}

         public void setPaused(String paused) {
		this.paused = paused;
	}

	public void setEncrypt(String encrypt) {
		if(encrypt!=null&&encrypt.equals("disable")){
			this.encryptEnabled="false";
		}
		if(encrypt!=null&&encrypt.equals("enable")){
			this.encryptEnabled="true";
		}
		if(encrypt!=null&&encrypt.equals("forced")){
			this.encryptForced="true";
		}
		this.encrypt = encrypt;
	}
	
	public void setAudioFormatsArray(String[] audioFormatsArray) {
		if(audioFormatsArray!=null){
			this.audioFormats=SimpleStringUtils.array2String(audioFormatsArray);
		}
		
		this.audioFormatsArray = audioFormatsArray;
	}
	
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getBeginLimit() {
		return beginLimit;
	}
	public void setBeginLimit(String beginLimit) {
		this.beginLimit = beginLimit;
	}
	public String getBeginTime() {
		return beginTime;
	}
	public void setBeginTime(String beginTime) {
		this.beginTime = beginTime;
	}
	public String getBandwidth() {
		return bandwidth;
	}
	public void setBandwidth(String bandwidth) {
		this.bandwidth = bandwidth;
	}
	public String getEncryptEnabled() {
		return encryptEnabled;
	}
	public void setEncryptEnabled(String encryptEnabled) {
		if(encryptEnabled!=null&&encryptEnabled.equals("true")){
			this.encrypt="enable";
		}
		if(encryptEnabled!=null&&encryptEnabled.equals("false")){
			this.encrypt="disable";
		}
		this.encryptEnabled = encryptEnabled;
	}
	public String getEncryptForced() {
		return encryptForced;
	}
	public void setEncryptForced(String encryptForced) {
		if(encryptForced!=null&&encryptForced.equals("true")){
			this.encrypt="forced";
		}
		this.encryptForced = encryptForced;
	}
	public String getCallInType() {
		return callInType;
	}
	public void setCallInType(String callInType) {
		this.callInType = callInType;
	}
	public String getUsers() {
		return users;
	}
	public void setUsers(String users) {
		this.users = users;
	}
	public String getEndLimit() {
		return endLimit;
	}
	public void setEndLimit(String endLimit) {
		this.endLimit = endLimit;
	}
	public String getEndTime() {
		return endTime;
	}
	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	public String getTopic() {
		return topic;
	}
	public void setTopic(String topic) {
		this.topic = topic;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getChairpassword() {
		return chairpassword;
	}
	public void setChairpassword(String chairpassword) {
		this.chairpassword = chairpassword;
	}
	public String getMaxAudioPorts() {
		return maxAudioPorts;
	}
	public void setMaxAudioPorts(String maxAudioPorts) {
		this.maxAudioPorts = maxAudioPorts;
	}
	public String getMaxVideoPorts() {
		return maxVideoPorts;
	}
	public void setMaxVideoPorts(String maxVideoPorts) {
		this.maxVideoPorts = maxVideoPorts;
	}
	public String getReservedAudioPorts() {
		return reservedAudioPorts;
	}
	public void setReservedAudioPorts(String reservedAudioPorts) {
		this.reservedAudioPorts = reservedAudioPorts;
	}
	public String getReservedVideoPorts() {
		return reservedVideoPorts;
	}
	public void setReservedVideoPorts(String reservedVideoPorts) {
		this.reservedVideoPorts = reservedVideoPorts;
	}
	public String getMuteOnJoin() {
		return muteOnJoin;
	}
	public void setMuteOnJoin(String muteOnJoin) {
		this.muteOnJoin = muteOnJoin;
	}

	public String getAudioFormats() {
		return audioFormats;
	}
	public void setAudioFormats(String audioFormats) {
		this.audioFormats = audioFormats;
	}
	public String getH263cif4Enabled() {
		return h263cif4Enabled;
	}
	public void setH263cif4Enabled(String h263cif4Enabled) {
		this.h263cif4Enabled = h263cif4Enabled;
	}
	public String getH264Enabled() {
		return h264Enabled;
	}
	public void setH264Enabled(String h264Enabled) {
		this.h264Enabled = h264Enabled;
	}
	public String getH264Definition() {
		return h264Definition;
	}
	public void setH264Definition(String h264Definition) {
		this.h264Definition = h264Definition;
	}
	public String getH239Bandwidth() {
		return h239Bandwidth;
	}
	public void setH239Bandwidth(String h239Bandwidth) {
		this.h239Bandwidth = h239Bandwidth;
	}
	public String getH239Enabled() {
		return h239Enabled;
	}
	public void setH239Enabled(String h239Enabled) {
		this.h239Enabled = h239Enabled;
	}
	public String getH239Codec() {
		return h239Codec;
	}
	public void setH239Codec(String h239Codec) {
		this.h239Codec = h239Codec;
	}
	public String getTextPosition() {
		return textPosition;
	}
	public void setTextPosition(String textPosition) {
		this.textPosition = textPosition;
	}
	public String getTextFont() {
		return textFont;
	}
	public void setTextFont(String textFont) {
		this.textFont = textFont;
	}
	public String getTextColor() {
		return textColor;
	}
	public void setTextColor(String textColor) {
		this.textColor = textColor;
	}
	public String getTextBgEnabled() {
		return textBgEnabled;
	}
	public void setTextBgEnabled(String textBgEnabled) {
		this.textBgEnabled = textBgEnabled;
	}
	public String getTextBgColor() {
		return textBgColor;
	}
	public void setTextBgColor(String textBgColor) {
		this.textBgColor = textBgColor;
	}
	public String getBroadcastEnabled() {
		return broadcastEnabled;
	}
	public void setBroadcastEnabled(String broadcastEnabled) {
		this.broadcastEnabled = broadcastEnabled;
	}
	public String getBroadcastBandwidth() {
		return broadcastBandwidth;
	}
	public void setBroadcastBandwidth(String broadcastBandwidth) {
		this.broadcastBandwidth = broadcastBandwidth;
	}
	public String getBroadcastPassword() {
		return broadcastPassword;
	}
	public void setBroadcastPassword(String broadcastPassword) {
		this.broadcastPassword = broadcastPassword;
	}
	public String getBroadcastNumLimit() {
		return broadcastNumLimit;
	}
	public void setBroadcastNumLimit(String broadcastNumLimit) {
		this.broadcastNumLimit = broadcastNumLimit;
	}
	public List<ConfParticipant> getParticipants() {
		return participants;
	}
	public void setParticipants(List<ConfParticipant> participants) {
		if(participants!=null&&!participants.isEmpty()){
			this.participantsJSON=JSONArray.fromObject(participants).toString();
		}
		this.participants = participants;
	}

	public String getParticipantsJSON() {
		return participantsJSON;
	}

	public void setParticipantsJSON(String participantsJSON) {
		this.participantsJSON = participantsJSON;
		
		if(this.participantsJSON!=null){
			JSONArray jArray=JSONArray.fromObject(this.participantsJSON);
			this.participants=(List)jArray.toCollection(jArray,ConfParticipant.class);
		}
	}

	public String getH263_1998Enabled() {
		return h263_1998Enabled;
	}

	public void setH263_1998Enabled(String h263_1998Enabled) {
		this.h263_1998Enabled = h263_1998Enabled;
	}

	public String getTextBgTransparency() {
		return textBgTransparency;
	}

	public void setTextBgTransparency(String textBgTransparency) {
		this.textBgTransparency = textBgTransparency;
	}

    public String getTextDisplayTime() {
		return textDisplayTime;
	}

	public void setTextDisplayTime(String textDisplayTime) {
		this.textDisplayTime = textDisplayTime;
	}

	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}
	
	
}
